import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# X，Y轴坐标刻度
# 1.xticks()和yticks()方法
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
# 传刻度和刻度的标签
plt.xticks([0, np.pi / 2, np.pi, np.pi * 1.5, np.pi * 2],
           ['0', '$\pi$/2', '$\pi$', '3$\pi$/2', '2$\pi$'], fontsize=20)
plt.yticks()
plt.show()

# 2.面向对象方法(set_xticks,set_xticklabels,set_yticks,set_yticklabels)
axes = plt.subplot()  #
axes.plot(x, y)
# 只能传刻度
axes.set_xticks([0, np.pi / 2, np.pi, np.pi * 1.5, np.pi * 2])
# 刻度的标签需要使用axes.set_xticklabels
axes.set_xticklabels(['0', '$\pi$/2', '$\pi$', '3$\pi$/2', '2$\pi$'])
plt.show()
